/*****************************************************************************

File:   otkGeometryExample.java

Date          Build     Author        Version    Comments
01-Nov-12    P-20-16    dshah          $$1        Created
02-Jan-14    P-20-44    rkumbhare      $$2        Updated for the fix of regfail.
20-mar-15 P-30-05 gshmelev $$3  called GetCurrentSession

****************************************************************************/


package com.ptc.otkjavaexamples;
 
import com.ptc.cipjava.*;
import com.ptc.pfc.pfcSession.*;
import com.ptc.pfc.pfcCommand.*;
import com.ptc.pfc.pfcGlobal.*;
import com.ptc.pfc.pfcModel.*;
import com.ptc.pfc.pfcModelItem.*;
import com.ptc.pfc.pfcFeature.*;
import com.ptc.pfc.pfcSolid.*;
import javax.swing.JOptionPane;
import java.io.*;

import com.ptc.cipjava.*;
import com.ptc.pfc.pfcFamily.*;
import com.ptc.pfc.pfcServer.*;
import com.ptc.pfc.pfcWindow.*;
import com.ptc.wfc.wfcSolid.*;
import com.ptc.wfc.wfcCombState.*;
import com.ptc.wfc.wfcPart.*;
import com.ptc.wfc.wfcModel.*;
import com.ptc.pfc.pfcPart.*;

/*
   This test is about
       - getting the interface data of the model
       - creating new part and importing the data as a feature in it.           
*/ 

class otkGeometryExample extends DefaultUICommandActionListener
{
    
    
    
    public otkGeometryExample()
    {
    }
	
    
    
    
    public void OnCommand()
    {
	addGeometryExample();
    }
    
    
    public void addGeometryExample ()
    {
	
	try
	    { 
		Session session = pfcSession.GetCurrentSession ();
		BaseSession bSession = (BaseSession)(session);
		
		Model model = (Model) session.GetCurrentModel();
		
		Solid pSolid = (Solid)(model);

		WSolid wSolid = (WSolid)(pSolid);
		
		WPart wPart = (WPart)(wSolid);
		
		EdgeRepresentation wEdgeRep = wfcPart.EdgeRepresentation_Create(1,1,1);
		
		ConversionOptions wConverOption = wfcPart.ConversionOptions_Create(wEdgeRep, CurveConversionOption.PART_CURVES_AS_DEFAULT, SurfaceConversionOption.PART_SURFACES_AS_DEFAULT);
		
		InterfaceData wIntfData = wPart.GetInterfaceData(wConverOption);
		
		/* Creating import feature using the interface data from above */		
		
	  	Part newPart = session.CreatePart ("MyIntfData");
		WPart newWPart = (WPart)(newPart);
		WSolid newWSolid = (WSolid)(newWPart);
		
		WIntfNeutral wIntfNeutral = wfcModel.WIntfNeutral_Create("myFile", wIntfData);
		IntfNeutral intfNeutral = (IntfNeutral)(wIntfNeutral);	
		
		newWSolid.ImportAsFeat ((IntfDataSource)intfNeutral, null, null, null, null);
	    }
	catch (Exception e)
	    {
		System.out.println("1: " + e);
	    }
	return;
    }
    
};






